package aa;


/**
 * 电动车父类，具有基本属性和方法
 */
public class ElectricVehicles {
    // 属性定义
    private String vehicleName;      // 车辆名称
    private String vehicleNumber;    // 车辆编号
    private double batteryCapacity;  // 电池容量，单位 kWh
    private String batteryType;      // 电池类型，铅酸或锂电池
    private double maxRange;         // 最大续航里程，单位 km
    private double maxSpeed;         // 最高速度，单位 km/h
    private double price;            // 价格，单位 元

    // 构造方法
    public ElectricVehicles(String vehicleName, String vehicleNumber, double batteryCapacity,
                            String batteryType, double maxRange, double maxSpeed, double price) {
        this.vehicleName = vehicleName;
        this.vehicleNumber = vehicleNumber;
        this.batteryCapacity = batteryCapacity;
        this.batteryType = batteryType;
        this.maxRange = maxRange;
        this.maxSpeed = maxSpeed;
        this.price = price;
    }

    // Getter 和 Setter 方法
    public String getVehicleName() {
        return vehicleName;
    }

    public void setVehicleName(String vehicleName) {
        this.vehicleName = vehicleName;
    }

    public String getVehicleNumber() {
        return vehicleNumber;
    }

    public void setVehicleNumber(String vehicleNumber) {
        this.vehicleNumber = vehicleNumber;
    }

    public double getBatteryCapacity() {
        return batteryCapacity;
    }

    public void setBatteryCapacity(double batteryCapacity) {
        this.batteryCapacity = batteryCapacity;
    }

    public String getBatteryType() {
        return batteryType;
    }

    public void setBatteryType(String batteryType) {
        this.batteryType = batteryType;
    }

    public double getMaxRange() {
        return maxRange;
    }

    public void setMaxRange(double maxRange) {
        this.maxRange = maxRange;
    }

    public double getMaxSpeed() {
        return maxSpeed;
    }

    public void setMaxSpeed(double maxSpeed) {
        this.maxSpeed = maxSpeed;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    // 重写 toString 方法，打印电动车的所有属性信息
    @Override
    public String toString() {
        return "ElectricVehicles{" +
                "车辆名称='" + vehicleName + '\'' +
                ", 车辆编号='" + vehicleNumber + '\'' +
                ", 电池容量=" + batteryCapacity + "kWh" +
                ", 电池类型='" + batteryType + '\'' +
                ", 最大续航里程=" + maxRange + "km" +
                ", 最高速度=" + maxSpeed + "km/h" +
                ", 价格=" + price + "元" +
                '}';
    }

    // 重写 equals 方法，比较两个电动车的车辆名称和车辆编号是否相同
    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null || getClass() != obj.getClass()) {
            return false;
        }
        ElectricVehicles that = (ElectricVehicles) obj;
        return vehicleName.equals(that.vehicleName) &&
                vehicleNumber.equals(that.vehicleNumber);
    }
}
